using System;
using BitMango;
using UnityEngine;
using UnityEngine.UI;

public class ConsentWorld : MonoBehaviour
{
	public void Initialize(BMConsentSetting setting)
	{
		this.termsOfServiceToggle.isOn = false;
		this.startButtonImage.sprite = this.buttonSprites[0];
		this.termsOfServiceURL = setting.termsOfServiceURL;
		this.privacyPolicyURL = setting.privacyPolicyURL;
		this.advertisingPartnersURL = setting.advertisingPartnersURL;
		this.termsOfServiceLabel.text = string.Format(this.termsOfServiceLabel.text, setting.companyDisplayName);
	}

	public void Show()
	{
		base.gameObject.SetActive(true);
	}

	public void Hide()
	{
		base.gameObject.SetActive(false);
	}

	public void OnClickTermsOfSercvicesLink()
	{
		Application.OpenURL(this.termsOfServiceURL);
	}

	public void OnClickPrivacyPolicyLink()
	{
		Application.OpenURL(this.privacyPolicyURL);
	}

	public void OnClickAdvertisingNetworksAndTheirPartnersLink()
	{
		Application.OpenURL(this.advertisingPartnersURL);
	}

	public void OnClickStartPlayingButton()
	{
		if (!this.termsOfServiceToggle.isOn)
		{
			return;
		}
		Platform.IsTOSAgreed = this.termsOfServiceToggle.isOn;
		if (this.OnDidClickStartPlaying != null)
		{
			this.OnDidClickStartPlaying();
		}
	}

	public void OnValueChangeTermsOfServiceToggle()
	{
		this.CheckToggleStatus();
	}

	private void CheckToggleStatus()
	{
		bool isOn = this.termsOfServiceToggle.isOn;
		this.startButtonImage.sprite = ((!isOn) ? this.buttonSprites[0] : this.buttonSprites[1]);
	}

	public Action OnDidClickStartPlaying;

	[SerializeField]
	private Toggle termsOfServiceToggle;

	[SerializeField]
	private Image startButtonImage;

	[SerializeField]
	private Sprite[] buttonSprites;

	[SerializeField]
	private Text termsOfServiceLabel;

	private string termsOfServiceURL;

	private string privacyPolicyURL;

	private string advertisingPartnersURL;
}
